package com.hp.provider;

import com.google.common.collect.Lists;
import com.hp.provider.dao.UserMapper;
import com.hp.provider.po.User;
import com.hp.provider.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import java.util.List;


@SpringBootApplication
@EnableDiscoveryClient
public class SpringDiscoveryProviderApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(SpringDiscoveryProviderApplication.class, args);
    }

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserService userService;

    @Override
    public void run(String... args) throws Exception {

        List<User> users = Lists.newArrayList();

        for (int i = 0; i < 10; i++) {
            users.add(User.builder().userName("王五" + i).password("pp" + i).build());
        }

//        this.userMapper.addUsers(users);
        userService.saveBatch(users);
    }
}
